/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "comments")
public class Comments extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Comments";
	public static final String ALIAS_COMMENT_ID = "commentId";
	public static final String ALIAS_MEMBER_ID = "memberId";
	public static final String ALIAS_PUBLISH_INFO_ID = "publishInfoId";
	public static final String ALIAS_CONTENTS = "contents";
	public static final String ALIAS_COMMENT_DATE = "commentDate";
	public static final String ALIAS_STATUS = "status";
	public static final String ALIAS_LEVEL = "level";
	public static final String ALIAS_UPDATE_TIME = "updateTime";
	public static final String ALIAS_COMMENT_IP = "commentIp";
	public static final String ALIAS_SUPPORTER = "supporter";
	public static final String ALIAS_OBJECTOR = "objector";
	public static final String ALIAS_IMPEACH = "impeach";
	public static final String ALIAS_ATTITUDE = "attitude";
	public static final String ALIAS_QUALITY = "quality";
	public static final String ALIAS_ATTITUDE1 = "attitude1";
	public static final String ALIAS_ATTITUDE2 = "attitude2";
	public static final String ALIAS_ATTITUDE3 = "attitude3";
	public static final String ALIAS_ATTITUDE4 = "attitude4";
	public static final String ALIAS_QUALITY1 = "quality1";
	public static final String ALIAS_QUALITY2 = "quality2";
	public static final String ALIAS_QUALITY3 = "quality3";
	public static final String ALIAS_QUALITY4 = "quality4";
	public static final String ALIAS_TYPE = "type";
	
	//date formats
	public static final String FORMAT_COMMENT_DATE = DATE_FORMAT;
	public static final String FORMAT_UPDATE_TIME = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * commentId       db_column: commentId 
     */ 	
	
	private java.lang.Long commentId;
    /**
     * memberId       db_column: memberId 
     */ 	
	
	private java.lang.Long memberId;
    /**
     * publishInfoId       db_column: publishInfoId 
     */ 	
	
	private java.lang.Long publishInfoId;
    /**
     * contents       db_column: contents 
     */ 	
	@Length(max=500)
	private java.lang.String contents;
    /**
     * commentDate       db_column: commentDate 
     */ 	
	@NotNull 
	private java.util.Date commentDate;
    /**
     * status       db_column: status 
     */ 	
	
	private java.lang.Integer status;
    /**
     * level       db_column: level 
     */ 	
	
	private java.lang.Integer level;
    /**
     * updateTime       db_column: updateTime 
     */ 	
	@NotNull 
	private java.util.Date updateTime;
    /**
     * commentIp       db_column: commentIp 
     */ 	
	@Length(max=255)
	private java.lang.String commentIp;
    /**
     * supporter       db_column: supporter 
     */ 	
	
	private java.lang.Integer supporter=0;
    /**
     * objector       db_column: objector 
     */ 	
	
	private java.lang.Integer objector=0;
    /**
     * impeach       db_column: impeach 
     */ 	
	
	private java.lang.Integer impeach=0;
    /**
     * attitude       db_column: attitude 
     */ 	
	
	private java.lang.Integer attitude=0;
    /**
     * quality       db_column: quality 
     */ 	
	
	private java.lang.Integer quality=0;
    /**
     * attitude1       db_column: attitude1 
     */ 	
	
	private java.lang.Integer attitude1=0;
    /**
     * attitude2       db_column: attitude2 
     */ 	
	
	private java.lang.Integer attitude2=0;
    /**
     * attitude3       db_column: attitude3 
     */ 	
	
	private java.lang.Integer attitude3=0;
    /**
     * attitude4       db_column: attitude4 
     */ 	
	
	private java.lang.Integer attitude4=0;
    /**
     * quality1       db_column: quality1 
     */ 	
	
	private java.lang.Integer quality1=0;
    /**
     * quality2       db_column: quality2 
     */ 	
	
	private java.lang.Integer quality2=0;
    /**
     * quality3       db_column: quality3 
     */ 	
	
	private java.lang.Integer quality3=0;
    /**
     * quality4       db_column: quality4 
     */ 	
	
	private java.lang.Integer quality4=0;
    /**
     * type       db_column: type 
     */ 	
	
	private java.lang.Integer type;
	//columns END


	public Comments(){
	}

	public Comments(
		java.lang.Long commentId
	){
		this.commentId = commentId;
	}

	

	public void setCommentId(java.lang.Long value) {
		this.commentId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "commentId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getCommentId() {
		return this.commentId;
	}
	
	@Column(name = "memberId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberId() {
		return this.memberId;
	}
	
	public void setMemberId(java.lang.Long value) {
		this.memberId = value;
	}
	
	@Column(name = "publishInfoId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getPublishInfoId() {
		return this.publishInfoId;
	}
	
	public void setPublishInfoId(java.lang.Long value) {
		this.publishInfoId = value;
	}
	
	@Column(name = "contents", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getContents() {
		return this.contents;
	}
	
	public void setContents(java.lang.String value) {
		this.contents = value;
	}
	
	@Transient
	public String getCommentDateString() {
		return DateConvertUtils.format(getCommentDate(), FORMAT_COMMENT_DATE);
	}
	public void setCommentDateString(String value) {
		setCommentDate(DateConvertUtils.parse(value, FORMAT_COMMENT_DATE,java.util.Date.class));
	}
	
	@Column(name = "commentDate", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	public java.util.Date getCommentDate() {
		return this.commentDate;
	}
	
	public void setCommentDate(java.util.Date value) {
		this.commentDate = value;
	}
	
	@Column(name = "status", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(java.lang.Integer value) {
		this.status = value;
	}
	
	@Column(name = "level", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getLevel() {
		return this.level;
	}
	
	public void setLevel(java.lang.Integer value) {
		this.level = value;
	}
	
	@Transient
	public String getUpdateTimeString() {
		return DateConvertUtils.format(getUpdateTime(), FORMAT_UPDATE_TIME);
	}
	public void setUpdateTimeString(String value) {
		setUpdateTime(DateConvertUtils.parse(value, FORMAT_UPDATE_TIME,java.util.Date.class));
	}
	
	@Column(name = "updateTime", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	public void setUpdateTime(java.util.Date value) {
		this.updateTime = value;
	}
	
	@Column(name = "commentIp", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getCommentIp() {
		return this.commentIp;
	}
	
	public void setCommentIp(java.lang.String value) {
		this.commentIp = value;
	}
	
	@Column(name = "supporter", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getSupporter() {
		return this.supporter;
	}
	
	public void setSupporter(java.lang.Integer value) {
		this.supporter = value;
	}
	
	@Column(name = "objector", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getObjector() {
		return this.objector;
	}
	
	public void setObjector(java.lang.Integer value) {
		this.objector = value;
	}
	
	@Column(name = "impeach", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getImpeach() {
		return this.impeach;
	}
	
	public void setImpeach(java.lang.Integer value) {
		this.impeach = value;
	}
	
	@Column(name = "attitude", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getAttitude() {
		return this.attitude;
	}
	
	public void setAttitude(java.lang.Integer value) {
		this.attitude = value;
	}
	
	@Column(name = "quality", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getQuality() {
		return this.quality;
	}
	
	public void setQuality(java.lang.Integer value) {
		this.quality = value;
	}
	
	@Column(name = "attitude1", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getAttitude1() {
		return this.attitude1;
	}
	
	public void setAttitude1(java.lang.Integer value) {
		this.attitude1 = value;
	}
	
	@Column(name = "attitude2", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getAttitude2() {
		return this.attitude2;
	}
	
	public void setAttitude2(java.lang.Integer value) {
		this.attitude2 = value;
	}
	
	@Column(name = "attitude3", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getAttitude3() {
		return this.attitude3;
	}
	
	public void setAttitude3(java.lang.Integer value) {
		this.attitude3 = value;
	}
	
	@Column(name = "attitude4", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getAttitude4() {
		return this.attitude4;
	}
	
	public void setAttitude4(java.lang.Integer value) {
		this.attitude4 = value;
	}
	
	@Column(name = "quality1", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getQuality1() {
		return this.quality1;
	}
	
	public void setQuality1(java.lang.Integer value) {
		this.quality1 = value;
	}
	
	@Column(name = "quality2", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getQuality2() {
		return this.quality2;
	}
	
	public void setQuality2(java.lang.Integer value) {
		this.quality2 = value;
	}
	
	@Column(name = "quality3", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getQuality3() {
		return this.quality3;
	}
	
	public void setQuality3(java.lang.Integer value) {
		this.quality3 = value;
	}
	
	@Column(name = "quality4", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getQuality4() {
		return this.quality4;
	}
	
	public void setQuality4(java.lang.Integer value) {
		this.quality4 = value;
	}
	
	@Column(name = "type", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getType() {
		return this.type;
	}
	
	public void setType(java.lang.Integer value) {
		this.type = value;
	}
	
	
	private Set complains = new HashSet(0);
	public void setComplains(Set<Complain> complain){
		this.complains = complain;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "comments")
	public Set<Complain> getComplains() {
		return complains;
	}
	
	private PublishInfo publishInfo;
	public void setPublishInfo(PublishInfo publishInfo){
		this.publishInfo = publishInfo;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "publishInfoId",nullable = false, insertable = false, updatable = false) 
	})
	public PublishInfo getPublishInfo() {
		return publishInfo;
	}
	
	private Members members;
	public void setMembers(Members members){
		this.members = members;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "memberId",nullable = false, insertable = false, updatable = false) 
	})
	public Members getMembers() {
		return members;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("CommentId",getCommentId())
			.append("MemberId",getMemberId())
			.append("PublishInfoId",getPublishInfoId())
			.append("Contents",getContents())
			.append("CommentDate",getCommentDate())
			.append("Status",getStatus())
			.append("Level",getLevel())
			.append("UpdateTime",getUpdateTime())
			.append("CommentIp",getCommentIp())
			.append("Supporter",getSupporter())
			.append("Objector",getObjector())
			.append("Impeach",getImpeach())
			.append("Attitude",getAttitude())
			.append("Quality",getQuality())
			.append("Attitude1",getAttitude1())
			.append("Attitude2",getAttitude2())
			.append("Attitude3",getAttitude3())
			.append("Attitude4",getAttitude4())
			.append("Quality1",getQuality1())
			.append("Quality2",getQuality2())
			.append("Quality3",getQuality3())
			.append("Quality4",getQuality4())
			.append("Type",getType())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getCommentId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Comments == false) return false;
		if(this == obj) return true;
		Comments other = (Comments)obj;
		return new EqualsBuilder()
			.append(getCommentId(),other.getCommentId())
			.isEquals();
	}
}

